<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <!--  <el-form-item label="工厂代码" prop="tenantId">
          <el-input
            v-model="queryParams.tenantId"
            placeholder="请输入工厂代码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>-->
      <el-form-item label="通知单编号" prop="noticeNum">
        <el-input
          v-model="queryParams.noticeNum"
          placeholder="请输入通知单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开票日期" prop="date">
        <el-date-picker clearable
                        v-model="queryParams.date"
                        type="month"
                        value-format="yyyy-MM"
                        format="yyyy-MM"
                        placeholder="请选择开票日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="伙伴代码" prop="partnerCode">
        <el-input
          v-model="queryParams.partnerCode"
          placeholder="请输入伙伴代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴名称" prop="partnerName">
        <el-input
          v-model="queryParams.partnerName"
          placeholder="请输入伙伴名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴类型" prop="partnerType">
        <el-input
          v-model="queryParams.partnerType"
          placeholder="请输入伙伴类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--<el-form-item label="伙伴税号" prop="partnerSh">
        <el-input
          v-model="queryParams.partnerSh"
          placeholder="请输入伙伴税号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴地址" prop="partnerDz">
        <el-input
          v-model="queryParams.partnerDz"
          placeholder="请输入伙伴地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴电话" prop="partnerPhone">
        <el-input
          v-model="queryParams.partnerPhone"
          placeholder="请输入伙伴电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴开户银行" prop="partnerKhyh">
        <el-input
          v-model="queryParams.partnerKhyh"
          placeholder="请输入伙伴开户银行"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴账号" prop="partnerZh">
        <el-input
          v-model="queryParams.partnerZh"
          placeholder="请输入伙伴账号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴联系人" prop="partnerLxr">
        <el-input
          v-model="queryParams.partnerLxr"
          placeholder="请输入伙伴联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴联系电话" prop="partnerLxdh">
        <el-input
          v-model="queryParams.partnerLxdh"
          placeholder="请输入伙伴联系电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同编号" prop="contractCode">
        <el-input
          v-model="queryParams.contractCode"
          placeholder="请输入合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同签订日期" prop="contractQdrq">
        <el-input
          v-model="queryParams.contractQdrq"
          placeholder="请输入合同签订日期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同交货期" prop="contractJhq">
        <el-input
          v-model="queryParams.contractJhq"
          placeholder="请输入合同交货期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同签订人" prop="contractQdr">
        <el-input
          v-model="queryParams.contractQdr"
          placeholder="请输入合同签订人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="产品编号" prop="proCode">
        <el-input
          v-model="queryParams.proCode"
          placeholder="请输入产品编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品名称" prop="proName">
        <el-input
          v-model="queryParams.proName"
          placeholder="请输入产品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="ggxh">
        <el-input
          v-model="queryParams.ggxh"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--<el-form-item label="单位" prop="unit">
        <el-input
          v-model="queryParams.unit"
          placeholder="请输入单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同金额" prop="contractJe">
        <el-input
          v-model="queryParams.contractJe"
          placeholder="请输入合同金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同单价" prop="contractDj">
        <el-input
          v-model="queryParams.contractDj"
          placeholder="请输入合同单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同数量" prop="contractNum">
        <el-input
          v-model="queryParams.contractNum"
          placeholder="请输入合同数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开票状态" prop="kpzt">
        <el-input
          v-model="queryParams.kpzt"
          placeholder="请输入开票状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <!--<el-form-item label="结算周期" prop="jiesuanZq">
        <el-input
          v-model="queryParams.jiesuanZq"
          placeholder="请输入结算周期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开票周期" prop="kpZq">
        <el-input
          v-model="queryParams.kpZq"
          placeholder="请输入开票周期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开票数量" prop="kpSl">
        <el-input
          v-model="queryParams.kpSl"
          placeholder="请输入开票数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开票单价" prop="kpDj">
        <el-input
          v-model="queryParams.kpDj"
          placeholder="请输入开票单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开票金额" prop="kpJe">
        <el-input
          v-model="queryParams.kpJe"
          placeholder="请输入开票金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="不含税单价" prop="bhsdj">
        <el-input
          v-model="queryParams.bhsdj"
          placeholder="请输入不含税单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="不含税金额" prop="bhdje">
        <el-input
          v-model="queryParams.bhdje"
          placeholder="请输入不含税金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="税率" prop="rate">
        <el-input
          v-model="queryParams.rate"
          placeholder="请输入税率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="税额" prop="rateE">
        <el-input
          v-model="queryParams.rateE"
          placeholder="请输入税额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="经办人" prop="chargeUser">
        <el-input
          v-model="queryParams.chargeUser"
          placeholder="请输入经办人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴方经办人" prop="partnerChargrUser">
        <el-input
          v-model="queryParams.partnerChargrUser"
          placeholder="请输入伙伴方经办人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAddAccount"
          :disabled="multiple"
          v-hasPermi="['business:bill:addJz']"
        >记账</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:bill:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:bill:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:bill:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:bill:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table  v-loading="loading" :data="billList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!--<el-table-column label="id" align="center" prop="id" />-->
      <el-table-column label="公司代码" align="center" prop="tenantId" />
      <el-table-column label="通知单编号" width="170" align="center" prop="noticeNum" />
      <el-table-column label="开票日期" align="center" prop="date" width="120"/>
      <el-table-column label="伙伴类型" align="center" prop="partnerType" />
      <el-table-column label="伙伴代码" width="120" show-overflow-tooltip align="center" prop="partnerCode" />
      <el-table-column label="伙伴名称" width="120" show-overflow-tooltip align="center" prop="partnerName" />
      <el-table-column label="伙伴税号" width="120" show-overflow-tooltip align="center" prop="partnerSh" />
      <el-table-column label="伙伴地址" width="120" show-overflow-tooltip align="center" prop="partnerDz" />
      <el-table-column label="伙伴电话" width="120" show-overflow-tooltip align="center" prop="partnerPhone" />
      <el-table-column label="伙伴开户银行" width="120" show-overflow-tooltip align="center" prop="partnerKhyh" />
      <el-table-column label="伙伴账号" width="120" show-overflow-tooltip align="center" prop="partnerZh" />
      <el-table-column label="伙伴联系人" width="120" show-overflow-tooltip align="center" prop="partnerLxr" />
      <el-table-column label="伙伴联系电话" width="120" show-overflow-tooltip align="center" prop="partnerLxdh" />
      <el-table-column label="合同类型" align="center" prop="contractType" />
      <el-table-column label="合同编号" width="120" show-overflow-tooltip align="center" prop="contractCode" />
      <el-table-column label="合同签订日期" width="120" align="center" prop="contractQdrq" />
      <el-table-column label="合同交货期" width="120" align="center" prop="contractJhq" />
      <el-table-column label="合同签订人" width="120" align="center" prop="contractQdr" />
      <el-table-column label="产品编号" width="180" show-overflow-tooltip align="center" prop="proCode" />
      <el-table-column label="产品名称" width="120" show-overflow-tooltip align="center" prop="proName" />
      <el-table-column label="规格型号" width="120" show-overflow-tooltip align="center" prop="ggxh" />
      <el-table-column label="单位" align="center" prop="unit" />
      <el-table-column label="合同金额" align="center" prop="contractJe" />
      <el-table-column label="合同单价" align="center" prop="contractDj" />
      <el-table-column label="合同数量" align="center" prop="contractNum" />
      <el-table-column label="开票状态" align="center" prop="kpzt" />
      <el-table-column label="发票类型" align="center" prop="invoiceType" />
      <el-table-column label="结算周期" align="center" prop="jiesuanZq" />
      <el-table-column label="开票周期" align="center" prop="kpZq" />
      <el-table-column label="开票数量" align="center" prop="kpSl" />
      <el-table-column label="开票单价" align="center" prop="kpDj" />
      <el-table-column label="开票金额" align="center" prop="kpJe" />
      <el-table-column label="不含税单价" width="120" align="center" prop="bhsdj" />
      <el-table-column label="不含税金额" width="120" align="center" prop="bhdje" />
      <el-table-column label="税率" align="center" prop="rate" />
      <el-table-column label="税额" align="center" prop="rateE" />
      <el-table-column label="经办人" align="center" prop="chargeUser" />
      <el-table-column label="伙伴方经办人" width="120"  align="center" prop="partnerChargrUser" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" fixed="right" width="120" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:bill:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:bill:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改开票通知单对话框 -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <!-- <el-form-item label="工厂代码" prop="tenantId">
           <el-input v-model="form.tenantId" placeholder="请输入工厂代码" />
         </el-form-item>-->
        <el-form-item label="开票日期" prop="date">
          <el-date-picker clearable
                          v-model="form.date"
                          type="month"
                          value-format="yyyy-MM"
                          format="yyyy-MM"
                          placeholder="请选择开票日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="伙伴代码" prop="partnerCode">
          <el-input v-model="form.partnerCode" placeholder="请输入伙伴代码" />
        </el-form-item>
        <el-form-item label="伙伴名称" prop="partnerName">
          <el-input v-model="form.partnerName" placeholder="请输入伙伴名称" />
        </el-form-item>
        <el-form-item label="伙伴税号" prop="partnerSh">
          <el-input v-model="form.partnerSh" placeholder="请输入伙伴税号" />
        </el-form-item>
        <el-form-item label="伙伴地址" prop="partnerDz">
          <el-input v-model="form.partnerDz" placeholder="请输入伙伴地址" />
        </el-form-item>
        <el-form-item label="伙伴电话" prop="partnerPhone">
          <el-input v-model="form.partnerPhone" placeholder="请输入伙伴电话" />
        </el-form-item>
        <el-form-item label="伙伴开户银行" prop="partnerKhyh">
          <el-input v-model="form.partnerKhyh" placeholder="请输入伙伴开户银行" />
        </el-form-item>
        <el-form-item label="伙伴账号" prop="partnerZh">
          <el-input v-model="form.partnerZh" placeholder="请输入伙伴账号" />
        </el-form-item>
        <el-form-item label="伙伴联系人" prop="partnerLxr">
          <el-input v-model="form.partnerLxr" placeholder="请输入伙伴联系人" />
        </el-form-item>
        <el-form-item label="伙伴联系电话" prop="partnerLxdh">
          <el-input v-model="form.partnerLxdh" placeholder="请输入伙伴联系电话" />
        </el-form-item>
        <el-form-item label="合同编号" prop="contractCode">
          <el-input v-model="form.contractCode" placeholder="请输入合同编号" />
        </el-form-item>
        <el-form-item label="合同签订日期" prop="contractQdrq">
          <el-input v-model="form.contractQdrq" placeholder="请输入合同签订日期" />
        </el-form-item>
        <el-form-item label="合同交货期" prop="contractJhq">
          <el-input v-model="form.contractJhq" placeholder="请输入合同交货期" />
        </el-form-item>
        <el-form-item label="合同签订人" prop="contractQdr">
          <el-input v-model="form.contractQdr" placeholder="请输入合同签订人" />
        </el-form-item>
        <el-form-item label="产品编号" prop="proCode">
          <el-input v-model="form.proCode" placeholder="请输入产品编号" />
        </el-form-item>
        <el-form-item label="产品名称" prop="proName">
          <el-input v-model="form.proName" placeholder="请输入产品名称" />
        </el-form-item>
        <el-form-item label="规格型号" prop="ggxh">
          <el-input v-model="form.ggxh" placeholder="请输入规格型号" />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入单位" />
        </el-form-item>
        <el-form-item label="合同金额" prop="contractJe">
          <el-input v-model="form.contractJe" placeholder="请输入合同金额" />
        </el-form-item>
        <el-form-item label="合同单价" prop="contractDj">
          <el-input v-model="form.contractDj" placeholder="请输入合同单价" />
        </el-form-item>
        <el-form-item label="合同数量" prop="contractNum">
          <el-input v-model="form.contractNum" placeholder="请输入合同数量" />
        </el-form-item>
        <el-form-item label="开票状态" prop="kpzt">
          <el-input v-model="form.kpzt" placeholder="请输入开票状态" />
        </el-form-item>
        <el-form-item label="通知单编号" prop="noticeNum">
          <el-input v-model="form.noticeNum" placeholder="请输入通知单编号" />
        </el-form-item>
        <el-form-item label="结算周期" prop="jiesuanZq">
          <el-input v-model="form.jiesuanZq" placeholder="请输入结算周期" />
        </el-form-item>
        <el-form-item label="开票周期" prop="kpZq">
          <el-input v-model="form.kpZq" placeholder="请输入开票周期" />
        </el-form-item>
        <el-form-item label="开票数量" prop="kpSl">
          <el-input v-model="form.kpSl" placeholder="请输入开票数量" />
        </el-form-item>
        <el-form-item label="开票单价" prop="kpDj">
          <el-input v-model="form.kpDj" placeholder="请输入开票单价" />
        </el-form-item>
        <el-form-item label="开票金额" prop="kpJe">
          <el-input v-model="form.kpJe" placeholder="请输入开票金额" />
        </el-form-item>
        <el-form-item label="不含税单价" prop="bhsdj">
          <el-input v-model="form.bhsdj" placeholder="请输入不含税单价" />
        </el-form-item>
        <el-form-item label="不含税金额" prop="bhdje">
          <el-input v-model="form.bhdje" placeholder="请输入不含税金额" />
        </el-form-item>
        <el-form-item label="税率" prop="rate">
          <el-input v-model="form.rate" placeholder="请输入税率" />
        </el-form-item>
        <el-form-item label="税额" prop="rateE">
          <el-input v-model="form.rateE" placeholder="请输入税额" />
        </el-form-item>
        <el-form-item label="经办人" prop="chargeUser">
          <el-input v-model="form.chargeUser" placeholder="请输入经办人" />
        </el-form-item>
        <el-form-item label="伙伴方经办人" prop="partnerChargrUser">
          <el-input v-model="form.partnerChargrUser" placeholder="请输入伙伴方经办人" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { listBill, getBill, delBill, addBill, updateBill } from "@/api/business/bill";
  import { billAddAccount } from "@/api/business/account";

  export default {
    name: "Bill",
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 开票通知单表格数据
        billList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          tenantId: null,
          date: null,
          partnerCode: null,
          partnerType: null,
          partnerName: null,
          partnerSh: null,
          partnerDz: null,
          partnerPhone: null,
          partnerKhyh: null,
          partnerZh: null,
          partnerLxr: null,
          partnerLxdh: null,
          contractType: null,
          contractCode: null,
          contractQdrq: null,
          contractJhq: null,
          contractQdr: null,
          proCode: null,
          proName: null,
          ggxh: null,
          unit: null,
          contractJe: null,
          contractDj: null,
          contractNum: null,
          kpzt: null,
          noticeNum: null,
          invoiceType: null,
          jiesuanZq: null,
          kpZq: null,
          kpSl: null,
          kpDj: null,
          kpJe: null,
          bhsdj: null,
          bhdje: null,
          rate: null,
          rateE: null,
          chargeUser: null,
          partnerChargrUser: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询开票通知单列表 */
      getList() {
        this.loading = true;
        listBill(this.queryParams).then(response => {
          this.billList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          tenantId: null,
          date: null,
          partnerCode: null,
          partnerType: null,
          partnerName: null,
          partnerSh: null,
          partnerDz: null,
          partnerPhone: null,
          partnerKhyh: null,
          partnerZh: null,
          partnerLxr: null,
          partnerLxdh: null,
          contractType: null,
          contractCode: null,
          contractQdrq: null,
          contractJhq: null,
          contractQdr: null,
          proCode: null,
          proName: null,
          ggxh: null,
          unit: null,
          contractJe: null,
          contractDj: null,
          contractNum: null,
          kpzt: null,
          noticeNum: null,
          invoiceType: null,
          jiesuanZq: null,
          kpZq: null,
          kpSl: null,
          kpDj: null,
          kpJe: null,
          bhsdj: null,
          bhdje: null,
          rate: null,
          rateE: null,
          chargeUser: null,
          partnerChargrUser: null,
          remark: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加开票通知单";
      },
      /** 生成开票通知单 */
      handleAddAccount(row) {
        const ids = row.id || this.ids;
        this.$modal.confirm('确定增加开票记账？').then(function() {
          return billAddAccount(ids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("生成成功");
        }).catch(() => {});
      },

      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getBill(id).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改开票通知单";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != null) {
              updateBill(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addBill(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$modal.confirm('是否确认删除开票通知单编号为"' + ids + '"的数据项？').then(function() {
          return delBill(ids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('business/bill/export', {
          ...this.queryParams
        }, `bill_${new Date().getTime()}.xlsx`)
      }
    }
  };
</script>
